import {createRouter, createWebHistory} from 'vue-router'
// import store from "@/store";
// import {notification} from "ant-design-vue";

const routes = [
    {
        path: '/',
        /*meta: {
            loginRequire: true
        },*/
        component: () => import('../views/panel'),
        children: [
            {
                path: 'welcome',
                component: () => import('../views/main/welcome'),
            }, {
                path: 'about',
                component: () => import('../views/main/about'),
            }, {
                path: 'base/',
                children: [
                    {
                        path: 'station',
                        component: () => import('../views/main/base/station'),
                    }, {
                        path: 'train-station',
                        component: () => import('../views/main/base/train-station'),
                    }, {
                        path: 'train',
                        component: () => import('../views/main/base/train'),
                    }, {
                        path: 'train-carriage',
                        component: () => import('../views/main/base/train-carriage'),
                    }, {
                        path: 'train-seat',
                        component: () => import('../views/main/base/train-seat'),
                    }]
            }, {
                path: 'batch/',
                children: [{
                    path: 'job',
                    component: () => import('../views/main/batch/job')
                }]
            }, {
                path: 'business/',
                children: [
                    {
                        path: 'sk-token',
                        component: ()=>import('../views/main/business/sk-token')
                    }, {
                        path: 'daily-train',
                        component: ()=>import('../views/main/business/daily-train')
                    },{
                        path: 'daily-train-station',
                        component: () => import('../views/main/business/daily-train-station'),
                    }, {
                        path: 'daily-train-carriage',
                        component: () => import('../views/main/business/daily-train-carriage'),
                    },{
                        path: 'daily-train-seat',
                        component: () => import('../views/main/business/daily-train-seat.vue'),
                    },{
                        path: 'daily-train-ticket',
                        component: () => import('../views/main/business/daily-train-ticket'),
                    },{
                        path: 'confirm-order',
                        component: () => import('../views/main/business/confirm-order'),
                    }]
            },{
                path: 'member/',
                children: [{
                    path: 'ticket',
                    component: () => import('../views/main/member/ticket.vue')
                }]
            }],
    }, {
        path: '',
        redirect: '/welcome'
    } /*{
        path: '/login',
        name: 'login',
        component: () => import('../views/login')
    }*/]

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})

// 路由登录拦截
/*
router.beforeEach((to, from, next) => {
    // 要不要对meta.loginRequire属性做监控拦截
    if (to.matched.some(function (item) {
        console.log(item, "是否需要登录校验：", item.meta.loginRequire || false);
        return item.meta.loginRequire
    })) {
        const _member = store.state.member;
        console.log("页面登录校验开始：", _member);
        if (!_member.token) {
            console.log("用户未登录或登录超时！");
            notification.error({description: "未登录或登录超时"});
            next('/login');
        } else {
            next();
        }
    } else {
        next();
    }
});
*/

export default router
